package com.glsc.ngateway.common.base.converter.oaflow;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.api.oaflow.dto.oaflow.WorkflowRequestbaseDto;
import com.glsc.ngateway.common.base.domain.oracle.ecology.WorkflowRequestbase;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author xuchang
 */
public class WorkflowRequestbaseConverter {

    public static WorkflowRequestbaseDto do2Dto(WorkflowRequestbase domain) {
        if (Objects.isNull(domain)) {
            return null;
        }
        return WorkflowRequestbaseMapper.INSTANCE.do2Dto(domain);
    }

    public static List<WorkflowRequestbaseDto> do2Dto(List<WorkflowRequestbase> domainList) {
        return CollectionUtils.isEmpty(domainList) ? java.util.Collections.emptyList() : domainList.stream().map(WorkflowRequestbaseConverter::do2Dto).collect(Collectors.toList());
    }

    public static WorkflowRequestbase dto2Do(WorkflowRequestbaseDto dto) {
        if (Objects.isNull(dto)) {
            return null;
        }
        return WorkflowRequestbaseMapper.INSTANCE.dto2Do(dto);
    }

    public static List<WorkflowRequestbase> dto2Do(List<WorkflowRequestbaseDto> dtoList) {
        return CollectionUtils.isEmpty(dtoList) ? java.util.Collections.emptyList() : dtoList.stream().map(WorkflowRequestbaseConverter::dto2Do).collect(Collectors.toList());
    }

    @Mapper(componentModel = "spring")
    public interface WorkflowRequestbaseMapper {

        WorkflowRequestbaseMapper INSTANCE = Mappers.getMapper(WorkflowRequestbaseMapper.class);

        WorkflowRequestbaseDto do2Dto(WorkflowRequestbase domain);

        List<WorkflowRequestbaseDto> do2Dto(List<WorkflowRequestbase> domain);

        WorkflowRequestbase dto2Do(WorkflowRequestbaseDto dto);

        List<WorkflowRequestbase> dto2Do(List<WorkflowRequestbaseDto> dto);
    }
}
